<?php
/* SVN FILE: $Id: ibmarket_mysql_tables.php 228 2009-09-25 15:24:18Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* ibMarket SQL installation create and alter queries
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 228 $
* @lastrevision $Date: 2009-09-25 15:24:18 +0000 (Fri, 25 Sep 2009) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2009-09-25 15:24:18 +0000 (Fri, 25 Sep 2009) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/setup/versions/install/sql/ibmarket_mysql_tables.php $
*/

$TABLE[] = "CREATE TABLE market_categories (
  cat_id int(10) NOT NULL auto_increment,
  cat_parent_id int(10) NOT NULL default '-1',
  cat_icon varchar(255) NOT NULL default '',
  cat_name varchar(255) NOT NULL default '',
  cat_description text NOT NULL,
  price_multiplier float(15,10) NOT NULL default '1.0000000000',
  cat_tax float(15,10) NOT NULL default '0.0000000000',
  cat_order smallint(5) NOT NULL default '0',
  seo_name varchar(255) NOT NULL default '',
  PRIMARY KEY  (cat_id)
);";
$TABLE[] = "CREATE TABLE market_items (
  item_id int(10) NOT NULL auto_increment,
  filename varchar(255) NOT NULL default '',
  item_name varchar(255) NOT NULL default '',
  item_description text NOT NULL,
  category int(10) NOT NULL default '0',
  icon varchar(255) NOT NULL default '',
  hide_item tinyint(1) NOT NULL default '0',
  base_price bigint(19) NOT NULL default '0',
  base_resell bigint(19) NOT NULL default '0',
  tax float(15,10) NOT NULL default '0.0000000000',
  stock int(10) NOT NULL default '0',
  allow_resell tinyint(1) NOT NULL default '0',
  resell_putback tinyint(1) NOT NULL default '0',
  restock tinyint(1) NOT NULL default '0',
  restock_when int(10) NOT NULL default '-1',
  restock_minute smallint(2) NOT NULL default '0',
  restock_hour smallint(2) NOT NULL default '0',
  restock_day mediumint(3) NOT NULL default '0',
  restock_howmuch int(10) NOT NULL default '0',
  restock_time int(10) NOT NULL default '0',
  inventory_limit int(10) NOT NULL default '0',
  item_config text NOT NULL,
  settings text NOT NULL,
  limit_buy text NOT NULL,
  limit_use text NOT NULL,
  expire_time int(10) NOT NULL default '0',
  expire_unit int(10) NOT NULL default '0',
  PRIMARY KEY  (item_id)
);";
$TABLE[] = "CREATE TABLE market_inventory (
  i_id int(10) NOT NULL auto_increment,
  member_id mediumint(8) NOT NULL default '0',
  item int(10) NOT NULL default '0',
  price_bought bigint(19) NOT NULL default '0',
  resell_price bigint(19) NOT NULL default '0',
  time_bought int(10) NOT NULL default '0',
  settings TEXT NOT NULL,
  expired int(10) NOT NULL default '0',
  PRIMARY KEY  (i_id),
  KEY member_id (member_id)
);";
$TABLE[] = "CREATE TABLE market_buy_logs (
  log_id int(10) NOT NULL auto_increment,
  method enum('buy','resell') NOT NULL default 'buy',
  member_id mediumint(8) NOT NULL default '0',
  item_id int(10) NOT NULL default '0',
  ip_address varchar(15) NOT NULL default '',
  time_bought int(10) NOT NULL default '0',
  quanity bigint(19) NOT NULL default '0',
  price_bought bigint(19) NOT NULL default '0',
  resell_price bigint(19) NOT NULL default '0',
  tax_total bigint(19) NOT NULL default '0',
  category int(10) NOT NULL default '0',
  item_name varchar(255) NOT NULL default '',
  item_description text NOT NULL,
  icon varchar(255) NOT NULL default '',
  category_name varchar(255) NOT NULL default '',
  PRIMARY KEY  (log_id),
  KEY member_id (member_id),
  KEY receipt_id (method,member_id,time_bought)
);";
$TABLE[] = "CREATE TABLE market_item_logs (
  l_id int(10) NOT NULL auto_increment,
  member_id mediumint(8) NOT NULL default '0',
  item_id int(10) NOT NULL default '0',
  inv_id int(10) NOT NULL default '0',
  ip_address varchar(15) NOT NULL default '',
  l_time int(10) NOT NULL default '0',
  log_message text NOT NULL,
  PRIMARY KEY  (l_id)
);";
$TABLE[] = "CREATE TABLE market_plugins (
  directory varchar(255) NOT NULL default '',
  name varchar(255) NOT NULL default '',
  position mediumint(8) NOT NULL default '0',
  plugin_config text NOT NULL,
  view_permission mediumtext NOT NULL,
  use_permission mediumtext NOT NULL,
  seo_name varchar(255) NOT NULL default '',
  enabled tinyint(1) NOT NULL default '',
  PRIMARY KEY  (directory)
);";
$TABLE[] = "CREATE TABLE market_fee_logs (
  l_id int(10) NOT NULL auto_increment,
  member_id mediumint(8) NOT NULL default '0',
  l_time int(10) NOT NULL default '0',
  location varchar(255) NOT NULL default '',
  l_amount int(10) NOT NULL default '0',
  PRIMARY KEY  (l_id),
  KEY member_id (member_id)
);";
$TABLE[] = "CREATE TABLE market_reward_logs (
  l_id int(10) NOT NULL auto_increment,
  member_id mediumint(8) NOT NULL default '0',
  l_time int(10) NOT NULL default '0',
  location varchar(255) NOT NULL default '',
  l_amount int(10) NOT NULL default '0',
  PRIMARY KEY  (l_id)
);";
$TABLE[] = "CREATE TABLE market_wages (
  w_id mediumint(8) NOT NULL auto_increment,
  to_who enum('m','g') NOT NULL default 'm',
  id_who mediumint(8) NOT NULL default '0',
  how_much bigint(19) NOT NULL default '0',
  next_payment int(10) NOT NULL default '0',
  w_how tinyint(1) NOT NULL default '0',
  w_when int(10) NOT NULL default '0',
  w_day mediumint(3) NOT NULL default '0',
  w_hour smallint(2) NOT NULL default '0',
  w_minute smallint(2) NOT NULL default '0',
  PRIMARY KEY  (w_id)
);";
$TABLE[] = "CREATE TABLE market_wages_collected (
  c_id int(10) NOT NULL auto_increment,
  time_collected int(10) NOT NULL default '0',
  to_who enum('m','g') NOT NULL default 'm',
  id_who mediumint(8) NOT NULL default '0',
  how_much bigint(19) NOT NULL default '0',
  PRIMARY KEY  (c_id)
);";
$TABLE[] = "CREATE TABLE market_taxes (
  t_id int(11) NOT NULL auto_increment,
  applying enum('post','hand') NOT NULL default 'post',
  t_week tinyint(4) NOT NULL default '0',
  t_day tinyint(4) NOT NULL default '0',
  t_hour tinyint(4) NOT NULL default '0',
  t_minute tinyint(4) NOT NULL default '0',
  tax_fix bigint(20) NOT NULL default '0',
  tax_percent float(15,10) NOT NULL default '0.0000000000',
  tax_pmin bigint(20) NOT NULL default '0',
  tax_psub bigint(20) NOT NULL default '0',
  range_min bigint(20) NOT NULL default '0',
  range_max bigint(20) NOT NULL default '0',
  PRIMARY KEY  (t_id)
);";
$TABLE[] = "CREATE TABLE market_tax_logs (
  l_id int(11) NOT NULL auto_increment,
  member_id mediumint(9) NOT NULL default '0',
  tax_id int(11) NOT NULL default '0',
  amount bigint(20) NOT NULL default '0',
  l_time int(11) NOT NULL default '0',
  PRIMARY KEY  (l_id)
);";

$TABLE[] = "ALTER TABLE members ADD points BIGINT NOT NULL DEFAULT '0'";
$TABLE[] = "ALTER TABLE members ADD market_points BIGINT NOT NULL DEFAULT '0'";
$TABLE[] = "ALTER TABLE members ADD money BIGINT NOT NULL DEFAULT '0'";
$TABLE[] = "ALTER TABLE members ADD market_access TINYINT NOT NULL DEFAULT '-1'";
$TABLE[] = "ALTER TABLE members ADD market_tax FLOAT(15,10) NOT NULL DEFAULT '0.0000000000'";

$TABLE[] = "ALTER TABLE groups ADD g_market_tax FLOAT(15,10) NOT NULL DEFAULT '0.0000000000'";
$TABLE[] = "ALTER TABLE groups ADD g_market_view TINYINT NOT NULL DEFAULT '1'";
$TABLE[] = "ALTER TABLE groups ADD g_market_use TINYINT NOT NULL DEFAULT '1'";
$TABLE[] = "ALTER TABLE groups ADD g_market_discount FLOAT(15,10) NOT NULL DEFAULT '0'";

$TABLE[] = "ALTER TABLE forums ADD market_reply TINYINT NOT NULL DEFAULT '0'";
$TABLE[] = "ALTER TABLE forums ADD market_reply_amount BIGINT NOT NULL DEFAULT '0'";
$TABLE[] = "ALTER TABLE forums ADD market_topic TINYINT NOT NULL DEFAULT '0'";
$TABLE[] = "ALTER TABLE forums ADD market_topic_amount BIGINT NOT NULL DEFAULT '0'";

?>